<!--
 * @Author: HeAo
 * @Date: 2021-10-12 17:22:28
 * @LastEditTime: 2021-10-12 17:31:10
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \web2103-2105\web2103code\3-2-Vue\day04\10-el-button-homework.html
 * 别乱动！
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <el-button type="success">成功的按钮</el-button>
    <el-button type="danger">失败的按钮</el-button>
  </div>
  <script>
    Vue.component('el-button', {
      props: {
        type: {
          type: String,
          default: 'default'
        }
      },
      data() {
        return {
          style: {
            success: {
              backgroundColor: 'green',
              color: 'white'
            },
            danger: {
              backgroundColor: 'red',
              color: 'white'
            }
          }
        }
      },
      template: `
        <button :style="style[type]"><slot></slot></button>
      `
    })

    let vm = new Vue({
      el: '#app',
      data: {},
      methods: {},
      created() { }
    })
  </script>
</body>

</html>